using Chaotic.DataBase.DataAccess;
using Chaotic.DataBase.DBAccessLibrary.DBAccessLibrary;
using Chaotic.DataBase.DBAccessLibrary.Interface;
using Chaotic.DataBase.DBAccessLibrary.Model;

namespace Chaotic.DataBase.DBAccessLibrary.Grammar;

internal class MongoDbGrammar : DBGrammar, IGrammar, ILocalGrammar
{
	public string GetChTableSql => string.Empty;

	public string? IsExistChTableSql => string.Empty;

	public MongoDbGrammar(ConnectionModel? connect)
		: base(connect)
	{
	}

	private string GetTypeFilter(DatabaseType type, FieldEntity field, string sql)
	{
		string? typeName = field.TypeName;
		int.TryParse(field.Length, out var _);
		string? text = field.Length;
		string text2 = field.TypeName.ToUpper();
		if (text2 == "TIMESTAMP" || text2 == "DATE")
		{
			text = "";
		}
		return string.Format(sql, field.TableName, field.Name, typeName, text);
	}

	public string? AddColumn(FieldEntity? filed)
	{
		return string.Empty;
	}

	public IEnumerable<string?> EditColumn(FieldEntity? filed)
	{
		return new List<string?>();
	}

	public IEnumerable<string?> RemoveColumn(FieldEntity field)
	{
		return new List<string?>();
	}

	public string? SelectTop(TableEntity table, int count)
	{
		return string.Empty;
	}

	public string AppendTabText(string text)
	{
		return TabText(text);
	}

	public string GetErrorInfo(string errorMsg)
	{
		return string.Empty;
	}

	public string? GetProcParamInfo(ProcEntity entity)
	{
		return string.Empty;
	}

	public IEnumerable<string?> EditPrimary(TableEntity table)
	{
		return new List<string?>();
	}

	protected override string GetProcName(string sql, out string paramStr)
	{
		paramStr = string.Empty;
		return string.Empty;
	}

	public string GetPageingSql(string sql, decimal index, decimal count)
	{
		return sql;
	}

	public DatabaseType GetConnectionStr(out string connectStr)
	{
		connectStr = _connect.ConnectionStr;
		return DatabaseType.MongoDB;
	}
}
